package com.huilian.iotbox.admin.wap.controller;

import com.huilian.iotbox.admin.wap.service.PushConfigService;
import com.huilian.iotbox.admin.wap.service.UserService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.PushConfigDto;
import com.huilian.iotbox.data.enums.RoleEnum;
import com.huilian.iotbox.data.po.Qualification;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LinYinDong
 * @date 2024/1/9 10:56
 */
@RestController
@RequestMapping("/api/pushConfig")
public class PushConfigController {
    @Autowired
    private PushConfigService pushConfigService;
    @Autowired
    private UserService userService;

    /**
     * 查询消息推送，菜单
     */
    @PostMapping("/findPushConfigList")
    public ServerResponse findPushConfigList(HttpServletRequest request, @RequestBody PushConfigDto pushConfigDto) {
        UserInfo userInfo = userService.getLoginUserInfo(request);
        if (ObjectUtils.isEmpty(userInfo)) {
            return ServerResponse.createByErrorMessage("获取商户信息失败");
        }
        pushConfigDto.setUserId(userInfo.getId());
        pushConfigDto.setUserInfo(userInfo);
        return pushConfigService.findPushConfigList(pushConfigDto);
    }
}
